﻿using System;

public class Mapper078 : MapperDefault
{
    public override void init(NES nes)
    {
        base.init(nes);
    }

    public override void loadROM(ROM rom)
    {
        if (rom.Valid)
        {
            int num = rom.RomBankCount * 4;
            this.loadRomBank(0, 0x8000);
            this.loadRomBank(num - 1, 0xc000);
            this.loadCHRROM();
            base.nes.Cpu.requestIrq(2);
        }
    }

    public override void write(int address, short value_Renamed)
    {
        int bank = value_Renamed & 15;
        int num2 = (value_Renamed & 240) >> 4;
        if (address < 0x8000)
        {
            base.write(address, value_Renamed);
        }
        else
        {
            this.loadRomBank(bank, 0x8000);
            this.load8kVromBank(num2, 0);
            if ((address & 0xfe00) != 0xfe00)
            {
                if ((value_Renamed & 8) != 0)
                {
                    base.nes.Ppu.Mirroring = 4;
                }
                else
                {
                    base.nes.Ppu.Mirroring = 3;
                }
            }
        }
    }
}

